namespace QMVnSoft.DAL.Util
{    
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Windows.Forms;     

    public class FormRegister : Form
    {
        private Button btnCancel;
        private Button btnCreate;
        private Button btnSave;
        private IContainer components;
        private GroupBox gBoxControl1;
        private bool ib_CheckIDKey = true;
        private Label labelControl1;
        private Label labelControl2;
        private Label lblEnglishAddress;
        private Label lblEnglishName;
        private Label lblLocalAddress;
        private Label lblLocalName;
        private Label lblTaxCode;
        private DataRow oLocalCurrentRow;
        private DataTable oLocalDataTable;
        private TextBox txtEnglishAddress;
        private TextBox txtEnglishName;
        private TextBox txtLocalAddress;
        private TextBox txtLocalName;
        private TextBox txtSerial1;
        private TextBox txtSerial2;
        private TextBox txtSerial3;
        private TextBox txtSerial4;
        private TextBox txtSerial5;
        private TextBox txtTaxCode;

        public FormRegister()
        {
            this.InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btnCreate_Click(object sender, EventArgs e)
        {
            this.SetCompanyInfo();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.LocalCurrentRow != null)
            {
                FolderBrowserDialog dialog = new FolderBrowserDialog();
                dialog.ShowNewFolderButton = true;
                dialog.ShowDialog();
                if (Directory.Exists(dialog.SelectedPath))
                {
                    File.WriteAllText(dialog.SelectedPath + @"\license.dll", this.LocalCurrentRow["RegisteredFile"].ToString());
                }
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FindCompanyInfo()
        {
            string str1 = this.txtSerial1.Text.Trim();
            string str2 = this.txtSerial2.Text.Trim();
            string str3 = this.txtSerial3.Text.Trim();
            string str4 = this.txtSerial4.Text.Trim();
            string str5 = this.txtSerial5.Text.Trim();
            if (!AppSecurity.SoftwareDecode(0x8b, str1, str2, str3, str4, str5))
            {
                MessageBox.Show("Mã số khách hàng không chính xác!", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                string key = str1 + "-" + str2 + "-" + str3 + "-" + str4 + "-" + str5;
                if (this.LocalDataTable.Rows.Find(key) == null)
                {
                    MessageBox.Show("Mã số khách hàng không tồn tại!", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
                else
                {
                    this.LocalCurrentRow = this.LocalDataTable.Rows.Find(key);
                    this.txtTaxCode.Text = this.LocalCurrentRow["TaxCode"].ToString();
                    this.txtLocalName.Text = this.LocalCurrentRow["LocalName"].ToString();
                    this.txtEnglishName.Text = this.LocalCurrentRow["EnglishName"].ToString();
                    this.txtLocalAddress.Text = this.LocalCurrentRow["LocalAddress"].ToString();
                    this.txtEnglishAddress.Text = this.LocalCurrentRow["EnglishAddress"].ToString();
                    this.txtSerial1.ReadOnly = true;
                    this.txtSerial2.ReadOnly = true;
                    this.txtSerial3.ReadOnly = true;
                    this.txtSerial4.ReadOnly = true;
                    this.txtSerial5.ReadOnly = true;
                    this.txtTaxCode.ReadOnly = false;
                    this.txtLocalName.ReadOnly = false;
                    this.txtEnglishName.ReadOnly = false;
                    this.txtLocalAddress.ReadOnly = false;
                    this.txtEnglishAddress.ReadOnly = false;
                    this.txtTaxCode.Focus();
                    this.btnCreate.Enabled = true;
                    this.CheckIDKey = false;
                }
            }
        }

        private void InitializeComponent()
        {
            this.lblLocalName = new System.Windows.Forms.Label();
            this.txtLocalName = new System.Windows.Forms.TextBox();
            this.lblEnglishName = new System.Windows.Forms.Label();
            this.txtEnglishName = new System.Windows.Forms.TextBox();
            this.lblLocalAddress = new System.Windows.Forms.Label();
            this.txtLocalAddress = new System.Windows.Forms.TextBox();
            this.lblEnglishAddress = new System.Windows.Forms.Label();
            this.txtEnglishAddress = new System.Windows.Forms.TextBox();
            this.btnCancel = new System.Windows.Forms.Button();
            this.btnCreate = new System.Windows.Forms.Button();
            this.labelControl1 = new System.Windows.Forms.Label();
            this.gBoxControl1 = new System.Windows.Forms.GroupBox();
            this.txtSerial1 = new System.Windows.Forms.TextBox();
            this.txtSerial5 = new System.Windows.Forms.TextBox();
            this.txtSerial4 = new System.Windows.Forms.TextBox();
            this.txtSerial2 = new System.Windows.Forms.TextBox();
            this.txtSerial3 = new System.Windows.Forms.TextBox();
            this.labelControl2 = new System.Windows.Forms.Label();
            this.lblTaxCode = new System.Windows.Forms.Label();
            this.txtTaxCode = new System.Windows.Forms.TextBox();
            this.btnSave = new System.Windows.Forms.Button();
            this.gBoxControl1.SuspendLayout();
            this.SuspendLayout();
            // 
            // lblLocalName
            // 
            this.lblLocalName.AutoSize = true;
            this.lblLocalName.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblLocalName.Location = new System.Drawing.Point(12, 116);
            this.lblLocalName.Name = "lblLocalName";
            this.lblLocalName.Size = new System.Drawing.Size(58, 14);
            this.lblLocalName.TabIndex = 0;
            this.lblLocalName.Text = "Tên đơn vị";
            // 
            // txtLocalName
            // 
            this.txtLocalName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtLocalName.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtLocalName.Location = new System.Drawing.Point(107, 113);
            this.txtLocalName.Name = "txtLocalName";
            this.txtLocalName.ReadOnly = true;
            this.txtLocalName.Size = new System.Drawing.Size(295, 20);
            this.txtLocalName.TabIndex = 2;
            this.txtLocalName.Text = "Công ty TNHH phần mềm Quang Minh";
            // 
            // lblEnglishName
            // 
            this.lblEnglishName.AutoSize = true;
            this.lblEnglishName.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblEnglishName.Location = new System.Drawing.Point(12, 142);
            this.lblEnglishName.Name = "lblEnglishName";
            this.lblEnglishName.Size = new System.Drawing.Size(73, 14);
            this.lblEnglishName.TabIndex = 0;
            this.lblEnglishName.Text = "Tên tiếng Anh";
            // 
            // txtEnglishName
            // 
            this.txtEnglishName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtEnglishName.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtEnglishName.Location = new System.Drawing.Point(107, 139);
            this.txtEnglishName.Name = "txtEnglishName";
            this.txtEnglishName.ReadOnly = true;
            this.txtEnglishName.Size = new System.Drawing.Size(295, 20);
            this.txtEnglishName.TabIndex = 3;
            // 
            // lblLocalAddress
            // 
            this.lblLocalAddress.AutoSize = true;
            this.lblLocalAddress.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblLocalAddress.Location = new System.Drawing.Point(12, 168);
            this.lblLocalAddress.Name = "lblLocalAddress";
            this.lblLocalAddress.Size = new System.Drawing.Size(40, 14);
            this.lblLocalAddress.TabIndex = 0;
            this.lblLocalAddress.Text = "Địa chỉ";
            // 
            // txtLocalAddress
            // 
            this.txtLocalAddress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtLocalAddress.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtLocalAddress.Location = new System.Drawing.Point(107, 165);
            this.txtLocalAddress.Name = "txtLocalAddress";
            this.txtLocalAddress.ReadOnly = true;
            this.txtLocalAddress.Size = new System.Drawing.Size(295, 20);
            this.txtLocalAddress.TabIndex = 4;
            // 
            // lblEnglishAddress
            // 
            this.lblEnglishAddress.AutoSize = true;
            this.lblEnglishAddress.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblEnglishAddress.Location = new System.Drawing.Point(12, 194);
            this.lblEnglishAddress.Name = "lblEnglishAddress";
            this.lblEnglishAddress.Size = new System.Drawing.Size(88, 14);
            this.lblEnglishAddress.TabIndex = 0;
            this.lblEnglishAddress.Text = "Địa chỉ tiếng Anh";
            // 
            // txtEnglishAddress
            // 
            this.txtEnglishAddress.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtEnglishAddress.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtEnglishAddress.Location = new System.Drawing.Point(107, 191);
            this.txtEnglishAddress.Name = "txtEnglishAddress";
            this.txtEnglishAddress.ReadOnly = true;
            this.txtEnglishAddress.Size = new System.Drawing.Size(295, 20);
            this.txtEnglishAddress.TabIndex = 5;
            // 
            // btnCancel
            // 
            this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.btnCancel.Font = new System.Drawing.Font("Arial", 8.25F);
            this.btnCancel.Location = new System.Drawing.Point(282, 236);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new System.Drawing.Size(120, 23);
            this.btnCancel.TabIndex = 8;
            this.btnCancel.Text = "&Thoát (Esc)";
            this.btnCancel.UseVisualStyleBackColor = true;
            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
            // 
            // btnCreate
            // 
            this.btnCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnCreate.Font = new System.Drawing.Font("Arial", 8.25F);
            this.btnCreate.Location = new System.Drawing.Point(12, 236);
            this.btnCreate.Name = "btnCreate";
            this.btnCreate.Size = new System.Drawing.Size(120, 23);
            this.btnCreate.TabIndex = 6;
            this.btnCreate.Text = "&Lưu (F3)";
            this.btnCreate.UseVisualStyleBackColor = true;
            this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click);
            // 
            // labelControl1
            // 
            this.labelControl1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.labelControl1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.labelControl1.Location = new System.Drawing.Point(12, 223);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new System.Drawing.Size(390, 2);
            this.labelControl1.TabIndex = 0;
            // 
            // gBoxControl1
            // 
            this.gBoxControl1.Controls.Add(this.txtSerial1);
            this.gBoxControl1.Controls.Add(this.txtSerial5);
            this.gBoxControl1.Controls.Add(this.txtSerial4);
            this.gBoxControl1.Controls.Add(this.txtSerial2);
            this.gBoxControl1.Controls.Add(this.txtSerial3);
            this.gBoxControl1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.gBoxControl1.Location = new System.Drawing.Point(51, 12);
            this.gBoxControl1.Name = "gBoxControl1";
            this.gBoxControl1.Size = new System.Drawing.Size(312, 51);
            this.gBoxControl1.TabIndex = 0;
            this.gBoxControl1.TabStop = false;
            this.gBoxControl1.Text = "Mã số khách hàng - Customer code";
            // 
            // txtSerial1
            // 
            this.txtSerial1.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtSerial1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtSerial1.Location = new System.Drawing.Point(14, 20);
            this.txtSerial1.MaxLength = 4;
            this.txtSerial1.Name = "txtSerial1";
            this.txtSerial1.Size = new System.Drawing.Size(52, 20);
            this.txtSerial1.TabIndex = 0;
            this.txtSerial1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // txtSerial5
            // 
            this.txtSerial5.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtSerial5.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtSerial5.Location = new System.Drawing.Point(246, 20);
            this.txtSerial5.MaxLength = 4;
            this.txtSerial5.Name = "txtSerial5";
            this.txtSerial5.Size = new System.Drawing.Size(52, 20);
            this.txtSerial5.TabIndex = 4;
            this.txtSerial5.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // txtSerial4
            // 
            this.txtSerial4.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtSerial4.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtSerial4.Location = new System.Drawing.Point(188, 20);
            this.txtSerial4.MaxLength = 4;
            this.txtSerial4.Name = "txtSerial4";
            this.txtSerial4.Size = new System.Drawing.Size(52, 20);
            this.txtSerial4.TabIndex = 3;
            this.txtSerial4.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // txtSerial2
            // 
            this.txtSerial2.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtSerial2.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtSerial2.Location = new System.Drawing.Point(72, 20);
            this.txtSerial2.MaxLength = 4;
            this.txtSerial2.Name = "txtSerial2";
            this.txtSerial2.Size = new System.Drawing.Size(52, 20);
            this.txtSerial2.TabIndex = 1;
            this.txtSerial2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // txtSerial3
            // 
            this.txtSerial3.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtSerial3.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtSerial3.Location = new System.Drawing.Point(130, 20);
            this.txtSerial3.MaxLength = 4;
            this.txtSerial3.Name = "txtSerial3";
            this.txtSerial3.Size = new System.Drawing.Size(52, 20);
            this.txtSerial3.TabIndex = 2;
            this.txtSerial3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            // 
            // labelControl2
            // 
            this.labelControl2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.labelControl2.Font = new System.Drawing.Font("Arial", 8.25F);
            this.labelControl2.Location = new System.Drawing.Point(12, 74);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new System.Drawing.Size(390, 2);
            this.labelControl2.TabIndex = 10;
            // 
            // lblTaxCode
            // 
            this.lblTaxCode.AutoSize = true;
            this.lblTaxCode.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTaxCode.Location = new System.Drawing.Point(12, 90);
            this.lblTaxCode.Name = "lblTaxCode";
            this.lblTaxCode.Size = new System.Drawing.Size(60, 14);
            this.lblTaxCode.TabIndex = 0;
            this.lblTaxCode.Text = "Mã số thuế";
            // 
            // txtTaxCode
            // 
            this.txtTaxCode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTaxCode.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTaxCode.Location = new System.Drawing.Point(107, 87);
            this.txtTaxCode.Name = "txtTaxCode";
            this.txtTaxCode.ReadOnly = true;
            this.txtTaxCode.Size = new System.Drawing.Size(295, 20);
            this.txtTaxCode.TabIndex = 1;
            this.txtTaxCode.Text = "Công ty cổ phần phần mềm Quang Minh";
            // 
            // btnSave
            // 
            this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.btnSave.Font = new System.Drawing.Font("Arial", 8.25F);
            this.btnSave.Location = new System.Drawing.Point(147, 236);
            this.btnSave.Name = "btnSave";
            this.btnSave.Size = new System.Drawing.Size(120, 23);
            this.btnSave.TabIndex = 7;
            this.btnSave.Text = "&Ghi tệp đăng ký";
            this.btnSave.UseVisualStyleBackColor = true;
            this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
            // 
            // FormRegister
            // 
            this.CancelButton = this.btnCancel;
            this.ClientSize = new System.Drawing.Size(414, 271);
            this.Controls.Add(this.labelControl2);
            this.Controls.Add(this.gBoxControl1);
            this.Controls.Add(this.btnCancel);
            this.Controls.Add(this.btnSave);
            this.Controls.Add(this.btnCreate);
            this.Controls.Add(this.txtEnglishAddress);
            this.Controls.Add(this.labelControl1);
            this.Controls.Add(this.lblEnglishAddress);
            this.Controls.Add(this.txtLocalAddress);
            this.Controls.Add(this.lblLocalAddress);
            this.Controls.Add(this.txtEnglishName);
            this.Controls.Add(this.lblEnglishName);
            this.Controls.Add(this.txtTaxCode);
            this.Controls.Add(this.lblTaxCode);
            this.Controls.Add(this.txtLocalName);
            this.Controls.Add(this.lblLocalName);
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "FormRegister";
            this.Text = "Register";
            this.gBoxControl1.ResumeLayout(false);
            this.gBoxControl1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        private void LockCompanyInfo()
        {
            this.txtSerial1.ReadOnly = false;
            this.txtSerial2.ReadOnly = false;
            this.txtSerial3.ReadOnly = false;
            this.txtSerial4.ReadOnly = false;
            this.txtSerial5.ReadOnly = false;
            this.txtTaxCode.ReadOnly = true;
            this.txtLocalName.ReadOnly = true;
            this.txtEnglishName.ReadOnly = true;
            this.txtLocalAddress.ReadOnly = true;
            this.txtEnglishAddress.ReadOnly = true;
            this.txtSerial1.Focus();
            this.btnCreate.Enabled = false;
            this.CheckIDKey = true;
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
                case Keys.F3:
                    if (this.btnCreate.Enabled)
                    {
                        this.SetCompanyInfo();
                    }
                    break;

                case Keys.F4:
                    if (!this.CheckIDKey)
                    {
                        this.LockCompanyInfo();
                        break;
                    }
                    this.FindCompanyInfo();
                    break;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

        private void SetCompanyInfo()
        {
            if (this.LocalCurrentRow["RegisteredFile"].Equals(DBNull.Value) || (MessageBox.Show("Thông tin đã có, muốn lưu lại không?", "Xac nhan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.No))
            {
                DataTable table = new DataTable("CompanyInfo");
                DataColumn column = new DataColumn();
                column.ColumnName = "LocalName";
                column.DataType = System.Type.GetType("System.String");
                column.MaxLength = 128;
                DataColumn column2 = new DataColumn();
                column2.ColumnName = "EnglishName";
                column2.DataType = System.Type.GetType("System.String");
                column2.MaxLength = 128;
                DataColumn column3 = new DataColumn();
                column3.ColumnName = "LocalAddress";
                column3.DataType = System.Type.GetType("System.String");
                column3.MaxLength = 128;
                DataColumn column4 = new DataColumn();
                column4.ColumnName = "EnglishAddress";
                column4.DataType = System.Type.GetType("System.String");
                column4.MaxLength = 128;
                DataColumn column5 = new DataColumn();
                column5.ColumnName = "SoftwareSerialKey";
                column5.DataType = System.Type.GetType("System.String");
                column5.MaxLength = 128;
                //DataColumn column6 = new DataColumn();
                //column6.ColumnName = "SoftwareDateKey";
                //column6.DataType = System.Type.GetType("System.String");
                //column5.MaxLength = 128;
                table.Columns.Add(column);
                table.Columns.Add(column2);
                table.Columns.Add(column3);
                table.Columns.Add(column4);
                table.Columns.Add(column5);
                //table.Columns.Add(column6);
                string str1 = this.txtSerial1.Text.Trim();
                string str2 = this.txtSerial2.Text.Trim();
                string str3 = this.txtSerial3.Text.Trim();
                string str4 = this.txtSerial4.Text.Trim();
                string str5 = this.txtSerial5.Text.Trim();
                string str6 = str1 + "-" + str2 + "-" + str3 + "-" + str4 + "-" + str5;
                DataRow row = table.NewRow();
                UserDataAccess access = new UserDataAccess();
                row["LocalName"] = AppSecurity.Base64Encode(this.txtLocalName.Text);
                row["EnglishName"] = AppSecurity.Base64Encode(this.txtEnglishName.Text);
                row["LocalAddress"] = AppSecurity.Base64Encode(this.txtLocalAddress.Text);
                row["EnglishAddress"] = AppSecurity.Base64Encode(this.txtEnglishAddress.Text);
                row["SoftwareSerialKey"] = AppSecurity.Base64Encode(str6);
                //row["SoftwareDateKey"] = AppSecurity.Base64Encode("30/03/2012");
                table.Rows.Add(row);
                table.AcceptChanges();
                table.WriteXml(Application.CommonAppDataPath + "license.dll");
            
                this.LocalCurrentRow["TaxCode"] = this.txtTaxCode.Text;
                this.LocalCurrentRow["LocalName"] = this.txtLocalName.Text;
                this.LocalCurrentRow["EnglishName"] = this.txtEnglishName.Text;
                this.LocalCurrentRow["LocalAddress"] = this.txtLocalAddress.Text;
                this.LocalCurrentRow["EnglishAddress"] = this.txtEnglishAddress.Text;
                this.LocalCurrentRow["RegisteredFile"] = File.ReadAllText(Application.CommonAppDataPath + "license.dll");
                File.Delete(Application.CommonAppDataPath + "license.dll");
                this.LocalDataTable.WriteXml(@"D:\CardNumber.xml");
            }
        }

        private bool CheckIDKey
        {
            get
            {
                return this.ib_CheckIDKey;
            }
            set
            {
                this.ib_CheckIDKey = value;
            }
        }

        private DataRow LocalCurrentRow
        {
            get
            {
                return this.oLocalCurrentRow;
            }
            set
            {
                this.oLocalCurrentRow = value;
            }
        }

        private DataTable LocalDataTable
        {
            get
            {
                if (this.oLocalDataTable == null)
                {
                    this.oLocalDataTable = new DataTable("CardNumber");
                    DataColumn column = new DataColumn();
                    column.ColumnName = "CardNumber";
                    column.DataType = System.Type.GetType("System.String");
                    column.MaxLength = 0x18;
                    DataColumn column2 = new DataColumn();
                    column2.ColumnName = "CreatedDate";
                    column2.DataType = System.Type.GetType("System.DateTime");
                    DataColumn column3 = new DataColumn();
                    column3.ColumnName = "TaxCode";
                    column3.DataType = System.Type.GetType("System.String");
                    column3.MaxLength = 128;
                    DataColumn column4 = new DataColumn();
                    column4.ColumnName = "LocalName";
                    column4.DataType = System.Type.GetType("System.String");
                    column4.MaxLength = 128;
                    DataColumn column5 = new DataColumn();
                    column5.ColumnName = "EnglishName";
                    column5.DataType = System.Type.GetType("System.String");
                    column5.MaxLength = 128;
                    DataColumn column6 = new DataColumn();
                    column6.ColumnName = "LocalAddress";
                    column6.DataType = System.Type.GetType("System.String");
                    column6.MaxLength = 128;
                    DataColumn column7 = new DataColumn();
                    column7.ColumnName = "EnglishAddress";
                    column7.DataType = System.Type.GetType("System.String");
                    column7.MaxLength = 128;
                    DataColumn column8 = new DataColumn();
                    column8.ColumnName = "RegisteredFile";
                    column8.DataType = System.Type.GetType("System.String");
                    this.oLocalDataTable.Columns.Add(column);
                    this.oLocalDataTable.Columns.Add(column2);
                    this.oLocalDataTable.Columns.Add(column3);
                    this.oLocalDataTable.Columns.Add(column4);
                    this.oLocalDataTable.Columns.Add(column5);
                    this.oLocalDataTable.Columns.Add(column6);
                    this.oLocalDataTable.Columns.Add(column7);
                    this.oLocalDataTable.Columns.Add(column8);
                    this.oLocalDataTable.PrimaryKey = new DataColumn[] { column };
                    if (File.Exists(@"D:\CardNumber.xml"))
                    {
                        this.oLocalDataTable.ReadXml(@"D:\CardNumber.xml");
                    }
                    else
                    {
                        MessageBox.Show("Không tồn tại file: D:\\CardNumber.xml");
                    }
                }
                return this.oLocalDataTable;
            }
        }
    }
}

